#define  _CRT_SECURE_NO_WARNINGS
struct ListNode* getIntersectionNode(struct ListNode* headA, struct ListNode* headB) {
    int count1 = 1;
    int count2 = 1;
    struct ListNode* cur1 = headA, * cur2 = headB;
    while (cur1->next)
    {
        count1++;
        cur1 = cur1->next;
    }
    while (cur2->next)
    {
        count2++;
        cur2 = cur2->next;
    }
    if (cur1 != cur2)
        return NULL;

    int k = abs(count1 - count2);
    struct ListNode* longlist = headA;
    struct ListNode* shortlist = headB;
    if (count2 > count1)
    {
        longlist = headB;
        shortlist = headA;
    }
    while (k--)
    {
        longlist = longlist->next;
    }
    while (longlist != shortlist)
    {
        shortlist = shortlist->next;
        longlist = longlist->next;
    }
    return longlist;
}